<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>高等数学A</title>

    <!-- Markdown渲染样式 -->
    <link rel="stylesheet"
        href="../style/github-markdown.min.css">

    <!-- 代码高亮 -->
    <link rel="stylesheet" href="../style/prism.min.css">

    <style>
        
        @font-face {
            font-display: auto;
            font-family: font-x;
            src: url(../Assets/font/AlimamaFangYuanTiVF-Thin-2.ttf);
        }

        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Segoe UI', font-x;
        }

        body {
            background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
            padding: 2rem;
        }

        .container {
            max-width: 1200px;
            margin: 0 auto;
        }

        /* Markdown内容容器 */
        .markdown-body {
            background: white;
            padding: 2rem;
            border-radius: 15px;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
        }

        /* 调整Markdown样式与主站一致 */
        .markdown-body h1,
        .markdown-body h2 {
            color: #2980b9;
            border-bottom: 2px solid #3498db;
            padding-bottom: 0.5rem;
            margin: 1.5rem 0;
        }

        .markdown-body code {
            background: #f8f9fa;
            padding: 0.2em 0.4em;
            border-radius: 3px;
        }
        .markdown-body pre {
            background: #f8f9fa;
            padding: 1rem;
            border-radius: 8px;
            overflow-x: auto;
        }

        /* 导航按钮 */
        .nav-button {
            display: inline-block;
            padding: 0.8rem 1.5rem;
            background: #3498db;
            color: white;
            text-decoration: none;
            border-radius: 25px;
            margin: 1rem 0;
            transition: all 0.3s ease;
        }

        .nav-button:hover {
            background: #2980b9;
            transform: translateY(-2px);
        }

        footer {
            margin-top: 1.5rem;
            text-align: center;
        }

        /* 响应式调整 */
        @media (max-width: 768px) {
            .markdown-body {
                padding: 1rem;
            }
            .markdown-body h1{
                font-size: 1.7rem !important;
            }
        }
    </style>
</head>

<body>
    <div class="container">
        <a href="../index.html" class="nav-button">← 返回主页面</a>

        <div class="markdown-body" id="content">
            <!-- Markdown内容将通过JavaScript渲染到这里 -->
            正在加载内容...
        </div>

        <footer>
            © 2025-present All Rights Reserved by Shlorex
        </footer>
    </div>

    <!-- 依赖库 -->
    <script src="../scripts/prism-core.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.24.1/plugins/autoloader/prism-autoloader.min.js"></script>
    <script src="../scripts/marked.min.js"></script>
    <script id="MathJax-script" async src="../scripts/tex-mml-chtml.js"></script>
    <script>
        // 加载并渲染Markdown文件
        async function loadMarkdown(url) {
            try {
                const response = await fetch(url);
                const text = await response.text();
                
                // 渲染Markdown
                document.getElementById('content').innerHTML = marked.parse(text);
                
                // 手动触发代码高亮（关键修复）
                Prism.highlightAllUnder(document.getElementById('content'));
                
            } catch (error) {
                document.getElementById('content').innerHTML = 
                    `❌ 加载失败: ${error.message}`;
            }
        }
        //根据不同参数选择不同md
        function getUrlPrama(name){
            let query = window.location.search.substring(1);
            let parma_all = query.split("&");
            for(let i=0;i<parma_all.length;i++){
                let pair = parma_all[i].split("=");
                if(pair[0] == name){
                    return pair[1];
                }
            }
            return (false);
        }
        let subject = getUrlPrama("subject");
        loadMarkdown(subject);
        // 配置Markdown解析器
        marked.setOptions({
            breaks: true,
            highlight: function (code, lang) {
                if (Prism.languages[lang]) {
                    return Prism.highlight(code, Prism.languages[lang], lang);
                }
                return code;
            }
        });

        // 自动添加标题锚点
        document.querySelectorAll('.markdown-body h1, .markdown-body h2').forEach(heading => {
            const anchor = document.createElement('a');
            anchor.className = 'anchor';
            anchor.href = `#${heading.id}`;
            heading.insertBefore(anchor, heading.firstChild);
        });
    </script>
</body>

</html>